package com.sfddata.musicpillow.gateway.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;
import javax.servlet.MultipartConfigElement;


/**
 * 文件上传配置类
 *
 * @Author mashanghaoyun
 * @Date 2020/11/11 01:34
 * @Version 1.0
 **/
@Configuration
public class FileUploadConfig {
    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize(DataSize.of(1000, DataUnit.MEGABYTES));
        /// 设置总上传数据总大小100M
        factory.setMaxRequestSize(DataSize.of(1000, DataUnit.MEGABYTES));
        return factory.createMultipartConfig();
    }

}

